package com.xhl.doeverything.entity;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xhl.doeverything.utils.MapHelper;

import java.util.Arrays;
import java.util.Map;

public interface BaseEnum extends IEnum<String> {
    static Map<String, String> getMap(BaseEnum[] list) {
        return MapHelper.uniqueIndex(Arrays.asList(list), BaseEnum::getCode, BaseEnum::getDesc);
    }

    default String getCode() {
        return this.toString();
    }

    String getDesc();

    @JsonIgnore
    default String getValue() {
        return this.getCode();
    }
}
